﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;

namespace Com.CMS263.DAO
{
    public class UserDocDAO : BaseService
    {
        public IList<UserDoc> GetListPaging(int ComId)
        {
            string hql = "from UserDoc where 1=1";
            hql += " and ComId = " + ComId;
            hql += " order By AddDate Desc";
            return FindList<UserDoc>(hql, null, null, null);
        }
        public UserDoc GetComm(int ComId)
        {
            string hql = "from UserDoc where 1=1";
            hql += " and ComId = " + ComId;
            hql += " order By AddDate Desc";
            try
            {
                return FindList<UserDoc>(hql, null, null, null).First();
            }
            catch (Exception)
            {

                return null;
            }

        }
        /// <summary>
        /// 根据登陆用户ID查询资料信息
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public IList<UserDoc> GetListPaing(int userid, int page, int pagesize)
        {
            string hql = "from UserDoc where 1=1 and IsDel=false and UserId=" + userid;
            return FindList<UserDoc>(hql, null, (page - 1) * pagesize, pagesize);
        }

        /// <summary>
        /// 根据登陆用户ID查询资料信息数量
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public int GetListPaing(int userid)
        {
            string hql = "select count(*) from UserDoc where 1=1 and IsDel=false and UserId=" + userid;
            return Convert.ToInt32(GetValue(hql));

        }
    }
}
